import 'package:flutter/material.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mesh/function/widgets/animated_tap_widget.dart';
import '../routes/app_route_manager.dart';

/// 登录弹窗组件
class LoginDialog extends StatelessWidget {
  final String title;
  final String message;

  const LoginDialog({
    super.key,
    this.title = 'Login Required',
    this.message = 'Please login to use this feature',
  });

  /// 显示登录弹窗
  static Future<void> show(
    BuildContext context, {
    String title = 'Login Required',
    String message = 'Please login to use this feature',
  }) {
    return showDialog<void>(
      context: context,
      barrierDismissible: true,
      builder: (BuildContext context) {
        return LoginDialog(title: title, message: message);
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.transparent,
      elevation: 0,
      child: Container(
        width: 320.w,
        decoration: BoxDecoration(
          color: const Color(0xFF663507),
          borderRadius: BorderRadius.circular(20.r),
          border: Border.all(color: const Color(0xFFFF8A3C), width: 1.w),
        ),
        child: Padding(
          padding: EdgeInsets.all(24.w),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              // 顶部图标
              Container(
                width: 60.w,
                height: 60.w,
                decoration: BoxDecoration(
                  color: const Color(0x33FF8A3C),
                  shape: BoxShape.circle,
                  border: Border.all(
                    color: const Color(0xFFFF8A3C),
                    width: 2.w,
                  ),
                ),
                child: Image.asset(
                  'assets/images/star.png',
                  width: 30.w,
                  height: 30.w,
                ),
              ),

              SizedBox(height: 20.h),

              // 标题
              Text(title)
                  .fontSize(20.sp)
                  .textColor(Colors.white)
                  .fontWeight(FontWeight.w700)
                  .fontFamily(
                    GoogleFonts.quicksand(
                      fontWeight: FontWeight.w700,
                    ).fontFamily,
                  ),

              SizedBox(height: 12.h),

              // 描述文字
              Text(message, textAlign: TextAlign.center)
                  .fontSize(14.sp)
                  .textColor(Colors.white.withOpacity(0.8))
                  .fontFamily(
                    GoogleFonts.quicksand(
                      fontWeight: FontWeight.w500,
                    ).fontFamily,
                  ),

              SizedBox(height: 24.h),

              // 按钮组
              Row(
                children: [
                  // 取消按钮
                  Expanded(
                    child: AnimatedTapButton(
                      onTap: () => Navigator.of(context).pop(),
                      child: Container(
                        height: 44.h,
                        decoration: BoxDecoration(
                          color: Colors.transparent,
                          borderRadius: BorderRadius.circular(12.r),
                          border: Border.all(
                            color: Colors.white.withOpacity(0.3),
                            width: 1.w,
                          ),
                        ),
                        child: Center(
                          child: Text('Cancel')
                              .fontSize(16.sp)
                              .textColor(Colors.white.withOpacity(0.8))
                              .fontWeight(FontWeight.w600)
                              .fontFamily(
                                GoogleFonts.quicksand(
                                  fontWeight: FontWeight.w600,
                                ).fontFamily,
                              ),
                        ),
                      ),
                    ),
                  ),

                  SizedBox(width: 12.w),

                  // 登录按钮
                  Expanded(
                    child: AnimatedTapButton(
                      onTap: () {
                        Navigator.of(context).pop();
                        AppRouteManager.navigateToAuth();
                      },
                      child: Container(
                        height: 44.h,
                        decoration: BoxDecoration(
                          color: const Color(0xFFFF8A3C),
                          borderRadius: BorderRadius.circular(12.r),
                        ),
                        child: Center(
                          child: Text('Login')
                              .fontSize(16.sp)
                              .textColor(Colors.white)
                              .fontWeight(FontWeight.w600)
                              .fontFamily(
                                GoogleFonts.quicksand(
                                  fontWeight: FontWeight.w600,
                                ).fontFamily,
                              ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
